﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Xml;
using Core;

namespace TestProject
{
    public partial class CreationForm : Form
    {
        private MainWindow mw;
        public CreationForm(MainWindow mw)
        {
            InitializeComponent();
            this.mw = mw;
        }

        private void browse_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog op = new FolderBrowserDialog();
            op.RootFolder = System.Environment.SpecialFolder.MyDocuments;
            if (op.ShowDialog() == DialogResult.OK)
            {
                path_box.Text = op.SelectedPath;
            }
        }

        private void create_button_Click(object sender, EventArgs e)
        {
            string model_path = path_box.Text + "\\" + name_box.Text+"\\"+name_box.Text+".xml";
            try
            {
                mw.model = new Model(model_path);             
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                this.Close();
            }
        }

        private void canc_creat_butt_Click(object sender, EventArgs e)
        {
            this.Close();
        }        
    }
}

